package threadlocal;

import com.sun.tools.javac.util.StringUtils;

public class ThreadLocalTest {

    static ThreadLocal<Long> threadLocal = new ThreadLocal<Long>();

    public static void main(String[] args) {
        System.out.println("test");
        Psk psk = new Psk();
        new Thread(psk).start();
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(psk).start();
    }

    static class Psk implements Runnable {


        public void run() {
            Long ruset = threadLocal.get();
            if (ruset == null) {

                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            threadLocal.set(System.currentTimeMillis());


            System.out.println(Thread.currentThread().getName() + threadLocal.get());
        }
    }

}
